import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * Created by Administrator on 2022/8/6.
 */
public class Demo {
    /*public static void main(String[] args) {
        //假设现在需要存储5个整型成绩
        int score1 = 70;
        int score2 = 80;
        int score3 = 85;
        int score4 = 60;
        int score5 = 90;
        System.out.println(score1);
        System.out.println(score2);
        System.out.println(score3);
        System.out.println(score4);
        System.out.println(score5);
        *//*像以上一个一个存储就很麻烦
        那我们就可以采用数组存储*//*
        *//*int[] score = new int[5];
        for (int i = 0; i < score.length; i++) {
            score[i] = i + 1;
        }//动态初始化*//*
        int[] score = {1,2,3,4,5};//静态初始化
        for (int i = 0; i < score.length; i++) {//通过数组长度遍历
            System.out.println(score[i]);
        }
        for (int x:score) {//通过foreach遍历
            System.out.println(x);
        }
    }*/

    /*public static void main(String[] args) {
        int a = 10;
        int[] arr = new int[]{1,2,3};
        arr[0] = 99;
    }*/

    /*public static void main(String[] args) {
        int[] arr = new int[]{1,2,3};
        func1(arr);
        System.out.println(arr[0]);
    }
    public static void func1(int[] arr){
        arr = new int[10];
        arr[0] = 99;
    }*/

    /*public static void main(String[] args) {
        int[] arr = new int[]{1,2,3};
        func1(arr);
        System.out.println(arr[0]);
    }
    public static void func1(int[] arr){
        arr[0] = 99;
    }*/

   /* public static void main(String[] args) {
        //获取斐波那契数列的前N项
        int n = 10;
        int[] arr = fib(n);
        System.out.println(Arrays.toString(arr));
    }
    public static int[] fib(int n){
        if(n == 0){
            return null;
        }
        int arr[] = new int[10];
        arr[0] = 1;
        arr[1] = 1;
        for(int i = 2;i < n;i++){
            arr[i] = arr[i-1] + arr[i-2];
        }
        return arr;
    }*/

    /*public static void main(String[] args) {
        //数组转字符串
        int[] arr = new int[]{1,2,3};
        System.out.println(Arrays.toString(arr));
    }*/

    /*public static void main(String[] args) {
        //数组拷贝
        int[] arr = new int[]{1,2,3};
        int[] brr = Arrays.copyOf(arr,arr.length);
        System.out.println(Arrays.toString(brr));
    }*/

    /*public static void main(String[] args) {
        //求数组中元素的平均值
        int[] arr = new int[]{1,2,3};
        int sum = 0;
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
            count++;
        }
        System.out.println(sum / count);
    }*/

    /*public static void main(String[] args) {
        //查找数组中指定元素(顺序查找)
        int[] arr = new int[]{1,2,3};
        int number = 2;
        int ret = find(arr,number);
        System.out.println(ret);
    }
    public static int find(int[] arr,int num){
        for (int i = 0; i < arr.length; i++) {
            if(num == arr[i]){
                return i;
            }
        }
        return -1;
    }*/

    /*public static void main(String[] args) {
        //查找数组中指定元素(二分查找)
        int[] arr = new int[]{1,2,3};
        int number = 2;
        int ret =  binarySearch(arr,number);
        System.out.println(ret);
    }
    public static int binarySearch(int[] arr,int num){
        int left = 0;
        int right = arr.length - 1;
        while(left <= right){
            int mid = (left + right) / 2;
            if(arr[mid] > num){
                right = mid - 1;
            }else if(arr[mid] < num){
                left = mid + 1;
            }else{
                return mid;
            }
        }
        return -1;
    }*/

    /*public static void main(String[] args) {
        //查找数组中指定元素(二分查找)
        int[] arr = new int[]{1,2,3};
        int number = 2;
        int ret =  Arrays.binarySearch(arr,number);
        System.out.println(ret);
    }*/

    /*public static void main(String[] args) {
        //数组排序(冒泡排序)
        int[] arr = new int[]{7,3,5,9,6,2,1};
        bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void bubbleSort(int[] arr){
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if(arr[j] > arr[j + 1]){
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }
            }
        }
    }*/

    /*public static void main(String[] args) {
        int[] arr = new int[]{7,3,5,9,6,2,1};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
    }*/

    /*public static void main(String[] args) {
        //二维数组
        int[][] arr = new int[][]{{1,2,3},{4,5,6}};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]);
            }
            System.out.println();
        }
    }*/

    public static void main(String[] args) {
        //二维数组
        int[][] arr = new int[][]{{1,2,3},{4,5,6}};
        for (int[] a: arr) {
            for (int x: a) {
                System.out.print(x);
            }
            System.out.println();
        }
    }
}
